<!DOCTYPE html><html><head>
      <title>&#x516D;&#x661F;&#x6559;&#x80B2;-mysql&#x4F18;&#x5316;-2-&#x7269;&#x5316;&#x89C6;&#x56FE;&#x4E0E;&#x4E8B;&#x52A1;</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      
      <link rel="stylesheet" href="file:///C:\Users\Administrator\.atom\packages\markdown-preview-enhanced\node_modules\@shd101wyy\mume\dependencies\katex\katex.min.css">
      
      
      
      
      
      
      
      
      

      <style> 
      /**
 * prism.js Github theme based on GitHub's theme.
 * @author Sam Clarke
 */
code[class*="language-"],
pre[class*="language-"] {
  color: #333;
  background: none;
  font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
  text-align: left;
  white-space: pre;
  word-spacing: normal;
  word-break: normal;
  word-wrap: normal;
  line-height: 1.4;

  -moz-tab-size: 8;
  -o-tab-size: 8;
  tab-size: 8;

  -webkit-hyphens: none;
  -moz-hyphens: none;
  -ms-hyphens: none;
  hyphens: none;
}

/* Code blocks */
pre[class*="language-"] {
  padding: .8em;
  overflow: auto;
  /* border: 1px solid #ddd; */
  border-radius: 3px;
  /* background: #fff; */
  background: #f5f5f5;
}

/* Inline code */
:not(pre) > code[class*="language-"] {
  padding: .1em;
  border-radius: .3em;
  white-space: normal;
  background: #f5f5f5;
}

.token.comment,
.token.blockquote {
  color: #969896;
}

.token.cdata {
  color: #183691;
}

.token.doctype,
.token.punctuation,
.token.variable,
.token.macro.property {
  color: #333;
}

.token.operator,
.token.important,
.token.keyword,
.token.rule,
.token.builtin {
  color: #a71d5d;
}

.token.string,
.token.url,
.token.regex,
.token.attr-value {
  color: #183691;
}

.token.property,
.token.number,
.token.boolean,
.token.entity,
.token.atrule,
.token.constant,
.token.symbol,
.token.command,
.token.code {
  color: #0086b3;
}

.token.tag,
.token.selector,
.token.prolog {
  color: #63a35c;
}

.token.function,
.token.namespace,
.token.pseudo-element,
.token.class,
.token.class-name,
.token.pseudo-class,
.token.id,
.token.url-reference .token.variable,
.token.attr-name {
  color: #795da3;
}

.token.entity {
  cursor: help;
}

.token.title,
.token.title .token.punctuation {
  font-weight: bold;
  color: #1d3e81;
}

.token.list {
  color: #ed6a43;
}

.token.inserted {
  background-color: #eaffea;
  color: #55a532;
}

.token.deleted {
  background-color: #ffecec;
  color: #bd2c00;
}

.token.bold {
  font-weight: bold;
}

.token.italic {
  font-style: italic;
}


/* JSON */
.language-json .token.property {
  color: #183691;
}

.language-markup .token.tag .token.punctuation {
  color: #333;
}

/* CSS */
code.language-css,
.language-css .token.function {
  color: #0086b3;
}

/* YAML */
.language-yaml .token.atrule {
  color: #63a35c;
}

code.language-yaml {
  color: #183691;
}

/* Ruby */
.language-ruby .token.function {
  color: #333;
}

/* Markdown */
.language-markdown .token.url {
  color: #795da3;
}

/* Makefile */
.language-makefile .token.symbol {
  color: #795da3;
}

.language-makefile .token.variable {
  color: #183691;
}

.language-makefile .token.builtin {
  color: #0086b3;
}

/* Bash */
.language-bash .token.keyword {
  color: #0086b3;
}

/* highlight */
pre[data-line] {
  position: relative;
  padding: 1em 0 1em 3em;
}
pre[data-line] .line-highlight-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  background-color: transparent;
  display: block;
  width: 100%;
}

pre[data-line] .line-highlight {
  position: absolute;
  left: 0;
  right: 0;
  padding: inherit 0;
  margin-top: 1em;
  background: hsla(24, 20%, 50%,.08);
  background: linear-gradient(to right, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0));
  pointer-events: none;
  line-height: inherit;
  white-space: pre;
}

pre[data-line] .line-highlight:before, 
pre[data-line] .line-highlight[data-end]:after {
  content: attr(data-start);
  position: absolute;
  top: .4em;
  left: .6em;
  min-width: 1em;
  padding: 0 .5em;
  background-color: hsla(24, 20%, 50%,.4);
  color: hsl(24, 20%, 95%);
  font: bold 65%/1.5 sans-serif;
  text-align: center;
  vertical-align: .3em;
  border-radius: 999px;
  text-shadow: none;
  box-shadow: 0 1px white;
}

pre[data-line] .line-highlight[data-end]:after {
  content: attr(data-end);
  top: auto;
  bottom: .4em;
}html body{font-family:"Helvetica Neue",Helvetica,"Segoe UI",Arial,freesans,sans-serif;font-size:16px;line-height:1.6;color:#333;background-color:#fff;overflow:initial;box-sizing:border-box;word-wrap:break-word}html body>:first-child{margin-top:0}html body h1,html body h2,html body h3,html body h4,html body h5,html body h6{line-height:1.2;margin-top:1em;margin-bottom:16px;color:#000}html body h1{font-size:2.25em;font-weight:300;padding-bottom:.3em}html body h2{font-size:1.75em;font-weight:400;padding-bottom:.3em}html body h3{font-size:1.5em;font-weight:500}html body h4{font-size:1.25em;font-weight:600}html body h5{font-size:1.1em;font-weight:600}html body h6{font-size:1em;font-weight:600}html body h1,html body h2,html body h3,html body h4,html body h5{font-weight:600}html body h5{font-size:1em}html body h6{color:#5c5c5c}html body strong{color:#000}html body del{color:#5c5c5c}html body a:not([href]){color:inherit;text-decoration:none}html body a{color:#08c;text-decoration:none}html body a:hover{color:#00a3f5;text-decoration:none}html body img{max-width:100%}html body>p{margin-top:0;margin-bottom:16px;word-wrap:break-word}html body>ul,html body>ol{margin-bottom:16px}html body ul,html body ol{padding-left:2em}html body ul.no-list,html body ol.no-list{padding:0;list-style-type:none}html body ul ul,html body ul ol,html body ol ol,html body ol ul{margin-top:0;margin-bottom:0}html body li{margin-bottom:0}html body li.task-list-item{list-style:none}html body li>p{margin-top:0;margin-bottom:0}html body .task-list-item-checkbox{margin:0 .2em .25em -1.8em;vertical-align:middle}html body .task-list-item-checkbox:hover{cursor:pointer}html body blockquote{margin:16px 0;font-size:inherit;padding:0 15px;color:#5c5c5c;border-left:4px solid #d6d6d6}html body blockquote>:first-child{margin-top:0}html body blockquote>:last-child{margin-bottom:0}html body hr{height:4px;margin:32px 0;background-color:#d6d6d6;border:0 none}html body table{margin:10px 0 15px 0;border-collapse:collapse;border-spacing:0;display:block;width:100%;overflow:auto;word-break:normal;word-break:keep-all}html body table th{font-weight:bold;color:#000}html body table td,html body table th{border:1px solid #d6d6d6;padding:6px 13px}html body dl{padding:0}html body dl dt{padding:0;margin-top:16px;font-size:1em;font-style:italic;font-weight:bold}html body dl dd{padding:0 16px;margin-bottom:16px}html body code{font-family:Menlo,Monaco,Consolas,'Courier New',monospace;font-size:.85em !important;color:#000;background-color:#f0f0f0;border-radius:3px;padding:.2em 0}html body code::before,html body code::after{letter-spacing:-0.2em;content:"\00a0"}html body pre>code{padding:0;margin:0;font-size:.85em !important;word-break:normal;white-space:pre;background:transparent;border:0}html body .highlight{margin-bottom:16px}html body .highlight pre,html body pre{padding:1em;overflow:auto;font-size:.85em !important;line-height:1.45;border:#d6d6d6;border-radius:3px}html body .highlight pre{margin-bottom:0;word-break:normal}html body pre code,html body pre tt{display:inline;max-width:initial;padding:0;margin:0;overflow:initial;line-height:inherit;word-wrap:normal;background-color:transparent;border:0}html body pre code:before,html body pre tt:before,html body pre code:after,html body pre tt:after{content:normal}html body p,html body blockquote,html body ul,html body ol,html body dl,html body pre{margin-top:0;margin-bottom:16px}html body kbd{color:#000;border:1px solid #d6d6d6;border-bottom:2px solid #c7c7c7;padding:2px 4px;background-color:#f0f0f0;border-radius:3px}@media print{html body{background-color:#fff}html body h1,html body h2,html body h3,html body h4,html body h5,html body h6{color:#000;page-break-after:avoid}html body blockquote{color:#5c5c5c}html body pre{page-break-inside:avoid}html body table{display:table}html body img{display:block;max-width:100%;max-height:100%}html body pre,html body code{word-wrap:break-word;white-space:pre}}.markdown-preview{width:100%;height:100%;box-sizing:border-box}.markdown-preview .pagebreak,.markdown-preview .newpage{page-break-before:always}.markdown-preview pre.line-numbers{position:relative;padding-left:3.8em;counter-reset:linenumber}.markdown-preview pre.line-numbers>code{position:relative}.markdown-preview pre.line-numbers .line-numbers-rows{position:absolute;pointer-events:none;top:1em;font-size:100%;left:0;width:3em;letter-spacing:-1px;border-right:1px solid #999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.markdown-preview pre.line-numbers .line-numbers-rows>span{pointer-events:none;display:block;counter-increment:linenumber}.markdown-preview pre.line-numbers .line-numbers-rows>span:before{content:counter(linenumber);color:#999;display:block;padding-right:.8em;text-align:right}.markdown-preview .mathjax-exps .MathJax_Display{text-align:center !important}.markdown-preview:not([for="preview"]) .code-chunk .btn-group{display:none}.markdown-preview:not([for="preview"]) .code-chunk .status{display:none}.markdown-preview:not([for="preview"]) .code-chunk .output-div{margin-bottom:16px}.scrollbar-style::-webkit-scrollbar{width:8px}.scrollbar-style::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}.scrollbar-style::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,0.66);border:4px solid rgba(150,150,150,0.66);background-clip:content-box}html body[for="html-export"]:not([data-presentation-mode]){position:relative;width:100%;height:100%;top:0;left:0;margin:0;padding:0;overflow:auto}html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{position:relative;top:0}@media screen and (min-width:914px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{padding:2em calc(50% - 457px)}}@media screen and (max-width:914px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{font-size:14px !important;padding:1em}}@media print{html body[for="html-export"]:not([data-presentation-mode]) #sidebar-toc-btn{display:none}}html body[for="html-export"]:not([data-presentation-mode]) #sidebar-toc-btn{position:fixed;bottom:8px;left:8px;font-size:28px;cursor:pointer;color:inherit;z-index:99;width:32px;text-align:center;opacity:.4}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] #sidebar-toc-btn{opacity:1}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc{position:fixed;top:0;left:0;width:300px;height:100%;padding:32px 0 48px 0;font-size:14px;box-shadow:0 0 4px rgba(150,150,150,0.33);box-sizing:border-box;overflow:auto;background-color:inherit}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar{width:8px}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,0.66);border:4px solid rgba(150,150,150,0.66);background-clip:content-box}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc a{text-decoration:none}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc ul{padding:0 1.6em;margin-top:.8em}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc li{margin-bottom:.8em}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc ul{list-style-type:none}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{left:300px;width:calc(100% -  300px);padding:2em calc(50% - 457px -  150px);margin:0;box-sizing:border-box}@media screen and (max-width:1274px){html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{width:100%}}html body[for="html-export"]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .markdown-preview{left:50%;transform:translateX(-50%)}html body[for="html-export"]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .md-sidebar-toc{display:none}
/* Please visit the URL below for more information: */
/*   https://shd101wyy.github.io/markdown-preview-enhanced/#/customize-css */
 
      </style>
    </head>
    <body for="html-export">
      <div class="mume markdown-preview   ">
      <h2 class="mume-header" id="1-%E7%89%A9%E5%8C%96%E8%A7%86%E5%9B%BE">1. &#x7269;&#x5316;&#x89C6;&#x56FE;</h2>

<p>&#x7269;&#x5316;&#x89C6;&#x56FE;&#x662F;&#x76F8;&#x5BF9;&#x4E8E;&#x89C6;&#x56FE;&#x800C;&#x8A00;&#x7684;&#xFF0C;&#x4F46;&#x662F;&#x4E24;&#x8005;&#x5B9E;&#x9645;&#x4E0A;&#x5E76;&#x6CA1;&#x6709;&#x4EC0;&#x4E48;&#x5173;&#x7CFB;&#x5C31;&#x5982;java/javaScript&#x4E00;&#x6837;</p>
<p>&#x9996;&#x5148;mysql&#x7684;&#x89C6;&#x56FE;&#x4E0D;&#x662F;&#x4E00;&#x79CD;&#x7269;&#x5316;&#x89C6;&#x56FE;&#xFF0C;&#x4ED6;&#x76F8;&#x5F53;&#x4E8E;&#x4E00;&#x4E2A;&#x865A;&#x62DF;&#x8868;&#xFF0C;&#x672C;&#x8EAB;&#x5E76;&#x4E0D;&#x5B58;&#x50A8;&#x6570;&#x636E;&#xFF0C;&#x5F53;sql&#x5728;&#x64CD;&#x4F5C;&#x89C6;&#x56FE;&#x65F6;&#x6240;&#x6709;&#x6570;&#x636E;&#x90FD;&#x662F;&#x4ECE;&#x5176;&#x4ED6;&#x8868;&#x4E2D;&#x67E5;&#x8BE2;&#x51FA;&#x6765;&#x7684;&#x3002;&#x8005;&#x5E26;&#x6765;&#x7684;&#x95EE;&#x9898;&#x662F;&#x4F7F;&#x7528;&#x89C6;&#x56FE;&#x5E76;&#x4E0D;&#x80FD;&#x5C06;&#x5E38;&#x7528;&#x6570;&#x636E;&#x5206;&#x79BB;&#x51FA;&#x6765;&#xFF0C;&#x4F18;&#x5316;&#x67E5;&#x8BE2;&#x901F;&#x5EA6;&#xFF0C;&#x5207;&#x64CD;&#x4F5C;&#x89C6;&#x56FE;&#x7684;&#x5F88;&#x591A;&#x547D;&#x4EE4;&#x548C;&#x666E;&#x901A;&#x6807;&#x4E00;&#x6837;&#xFF0C;&#x8FD9;&#x56DE;&#x5BFC;&#x81F4;&#x5728;&#x4E1A;&#x52A1;&#x4E2D;&#x65E0;&#x6CD5;&#x901A;&#x8FC7;sql&#x533A;&#x5206;&#x8868;&#x548C;&#x89C6;&#x56FE;&#xFF0C;&#x662F;&#x4EE3;&#x7801;&#x53D8;&#x5F97;&#x590D;&#x6742;&#x3002;</p>
<p>&#x89C6;&#x56FE;&#x662F;&#x7B80;&#x5316;&#x8BBE;&#x8BA1;&#xFF0C;&#x6E05;&#x6670;&#x7F16;&#x7801;&#x7684;&#x4E1C;&#x897F;&#xFF0C;&#x4ED6;&#x5E76;&#x4E0D;&#x662F;&#x63D0;&#x9AD8;&#x6027;&#x80FD;&#x7684;&#xFF0C;&#x4ED6;&#x7684;&#x5B58;&#x5728;&#x53EA;&#x4F1A;&#x964D;&#x4F4E;&#x6027;&#x80FD;&#xFF08;&#x5982;&#x4E00;&#x4E2A;&#x89C6;&#x56FE;7&#x4E2A;&#x8868;&#x5173;&#x8054;&#xFF0C;&#x53E6;&#x4E00;&#x4E2A;&#x89C6;&#x56FE;8&#x4E2A;&#x8868;&#xFF0C;&#x7A0B;&#x5E8F;&#x5458;&#x4E0D;&#x77E5;&#x9053;&#xFF0C;&#x89C9;&#x5F97;&#x5F88;&#x65B9;&#x4FBF;&#xFF0C;&#x628A;&#x4E24;&#x4E2A;&#x89C6;&#x56FE;&#x5173;&#x8054;&#x518D;&#x505A;&#x4E00;&#x4E2A;&#x89C6;&#x56FE;&#xFF0C;&#x90A3;&#x5C31;&#x60E8;&#x4E86;&#xFF09;&#xFF0C;&#x4ED6;&#x7684;&#x5B58;&#x5728;&#x672A;&#x4E86;&#x5728;&#x8BBE;&#x8BA1;&#x4E0A;&#x7684;&#x65B9;&#x4FBF;&#x6027;</p>
<p>&#x7269;&#x5316;&#x89C6;&#x56FE;&#x53EF;&#x4EE5;&#x5E2E;&#x52A9;&#x52A0;&#x5FEB;&#x4E25;&#x91CD;&#x4F9D;&#x8D56;&#x67D0;&#x4E9B;&#x805A;&#x5408;&#x7ED3;&#x679C;&#x7684;&#x67E5;&#x8BE2;&#x3002;<br>
&#x5982;&#x679C;&#x63D2;&#x5165;&#x901F;&#x5EA6;&#x4E0D;&#x662F;&#x95EE;&#x9898;&#xFF0C;&#x5219;&#x6B64;&#x529F;&#x80FD;&#x53EF;&#x4EE5;&#x5E2E;&#x52A9;&#x51CF;&#x5C11;&#x7CFB;&#x7EDF;&#x4E0A;&#x7684;&#x8BFB;&#x53D6;&#x8D1F;&#x8F7D;&#x3002;</p>
<pre data-role="codeBlock" data-info="sql" class="language-sql"><span class="token keyword">select</span> <span class="token function">count</span><span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token function">sum</span><span class="token punctuation">(</span>pro_price<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">sum</span><span class="token punctuation">(</span>pro_num<span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token function">avg</span><span class="token punctuation">(</span>pro_price<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">avg</span><span class="token punctuation">(</span>pro_num<span class="token punctuation">)</span> <span class="token keyword">from</span> purchase_order

&#x7269;&#x5316;&#x89C6;&#x56FE; &#x53EF;&#x4EE5;&#x7406;&#x89E3;&#x6210; &#x5C31;&#x662F;&#x5355;&#x72EC;&#x518D;&#x521B;&#x5EFA;&#x4E00;&#x5F20;&#x7EDF;&#x8BA1;&#x8868;&#x5417;

&#x628A;&#x6570;&#x636E;&#x8BB0;&#x5F55; <span class="token keyword">select</span> <span class="token function">count</span><span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token function">sum</span><span class="token punctuation">(</span>pro_price<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">sum</span><span class="token punctuation">(</span>pro_num<span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token function">avg</span><span class="token punctuation">(</span>pro_price<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">avg</span><span class="token punctuation">(</span>pro_num<span class="token punctuation">)</span> <span class="token keyword">from</span> purchase_order <span class="token operator">=</span><span class="token operator">&gt;&gt;</span>  purchase_mv

&#x6839;&#x636E;&#x9879;&#x76EE;&#x7684;&#x9700;&#x6C42; <span class="token punctuation">(</span>&#x6570;&#x636E;&#x5B9E;&#x65F6;&#x6027;<span class="token punctuation">)</span>
&#x8981;&#x5B9A;&#x65F6;&#x66F4;&#x65B0;&#x6570;&#x636E;<span class="token punctuation">,</span> <span class="token operator">=</span><span class="token operator">=</span><span class="token operator">&gt;&gt;</span> &#x5B58;&#x50A8;&#x8FC7;&#x7A0B; <span class="token keyword">call</span>
&#x5F00;&#x9500;&#x5C0F;<span class="token punctuation">,</span>&#x8BEF;&#x5DEE;&#x5927;&#x4E00;&#x70B9;

&#x4E2D;&#x95F4;&#x8868; &#x4F7F;&#x7528;&#x89C6;&#x56FE;&#x662F;&#x907F;&#x514D;&#x56E0;&#x4E3A; purchase_mv &#x8868;&#x7684;&#x7ED3;&#x679C;&#x4FEE;&#x6539;<span class="token punctuation">,</span>&#x800C;&#x5F71;&#x54CD;&#x5230;&#x5B58;&#x50A8;&#x8FC7;&#x7A0B;&#x4E0E;&#x89E6;&#x53D1;&#x5668;&#x7684;&#x67E5;&#x8BE2;<span class="token keyword">sql</span>&#x8BED;&#x53E5;&#x7684;&#x4FEE;&#x6539;
<span class="token keyword">create</span> <span class="token keyword">view</span> por_view <span class="token keyword">as</span>
	<span class="token keyword">select</span>
			supply_name<span class="token punctuation">,</span>
      <span class="token function">count</span><span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">)</span> pro_count<span class="token punctuation">,</span>
			<span class="token function">sum</span><span class="token punctuation">(</span>pro_price<span class="token punctuation">)</span> pro_price_sum<span class="token punctuation">,</span>
			<span class="token function">avg</span><span class="token punctuation">(</span>pro_price<span class="token punctuation">)</span> pro_price_avg<span class="token punctuation">,</span>
			<span class="token function">sum</span><span class="token punctuation">(</span>pro_num<span class="token punctuation">)</span> pro_num_sum<span class="token punctuation">,</span>
			<span class="token function">avg</span><span class="token punctuation">(</span>pro_num<span class="token punctuation">)</span> pro_num_avg
	<span class="token keyword">from</span>
			purchase_order
	<span class="token keyword">group</span> <span class="token keyword">by</span>
			supply_name<span class="token punctuation">;</span>

&#x5B9A;&#x65F6;&#x6267;&#x884C;&#x8FD9;&#x6837;&#x7684;<span class="token keyword">sql</span>
<span class="token keyword">insert</span> <span class="token keyword">into</span> purchase_mv <span class="token keyword">select</span> <span class="token operator">*</span> <span class="token keyword">from</span> por_view<span class="token punctuation">;</span>

&#x7B2C;&#x4E00;&#x6B65;&#x83B7;&#x53D6; &#x9700;&#x8981;&#x83B7;&#x53D6;&#x539F;&#x6709;&#x7EDF;&#x8BA1;&#x6570;&#x636E; <span class="token keyword">select</span> <span class="token operator">*</span> <span class="token keyword">from</span> por_view
&#x7B2C;&#x4E8C;&#x6B65;&#x5199;&#x5165; purchase_mv

<span class="token keyword">DROP</span> <span class="token keyword">PROCEDURE</span> refresh_mv_now<span class="token punctuation">;</span>
<span class="token keyword">DELIMITER</span> $$
<span class="token keyword">CREATE</span> <span class="token keyword">PROCEDURE</span> refresh_mv_now <span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token keyword">BEGIN</span>
  <span class="token keyword">TRUNCATE</span> <span class="token keyword">TABLE</span> purchase_mv<span class="token punctuation">;</span>
  <span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> purchase_mv <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> por_view<span class="token punctuation">;</span>
<span class="token keyword">END</span><span class="token punctuation">;</span>
$$
<span class="token keyword">DELIMITER</span> <span class="token punctuation">;</span>
<span class="token keyword">select</span> <span class="token operator">*</span> <span class="token keyword">from</span> purchase_mv<span class="token punctuation">;</span>

&#x5B9A;&#x65F6;&#x6267;&#x884C;&#x4E0B;&#x9762;&#x7684;<span class="token keyword">sql</span><span class="token punctuation">,</span>&#x4F60;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x4F60;&#x6240;&#x4F1A;&#x7684;&#x65B9;&#x6CD5;
<span class="token keyword">call</span> refresh_mv_now <span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

&#x5B9E;&#x65F6;&#x66F4;&#x65B0;&#x6570;&#x636E;<span class="token punctuation">,</span> <span class="token operator">=</span><span class="token operator">=</span><span class="token operator">&gt;&gt;</span> &#x89E6;&#x53D1;&#x5668; &#x4F7F;&#x7528;&#x89E6;&#x53D1;&#x5668;<span class="token punctuation">,</span>&#x662F;&#x5F88;&#x4F1A;&#x5F71;&#x54CD;&#x6570;&#x636E;&#x5E93;&#x7684;&#x5199;&#x64CD;&#x4F5C;&#x7684;&#x6027;&#x80FD;
&#x5F00;&#x9500;&#x5927;
<span class="token keyword">drop</span> <span class="token keyword">trigger</span> purchase_mv_trigger_ins<span class="token punctuation">;</span>
<span class="token keyword">DELIMITER</span> $$
<span class="token keyword">CREATE</span> <span class="token keyword">TRIGGER</span> purchase_mv_trigger_ins <span class="token keyword">AFTER</span> <span class="token keyword">INSERT</span> <span class="token keyword">ON</span> purchase_order <span class="token keyword">FOR EACH ROW</span>
<span class="token keyword">BEGIN</span>
	<span class="token keyword">SET</span> <span class="token variable">@old_pro_price_sum</span> <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
	<span class="token keyword">SET</span> <span class="token variable">@old_pro_price_avg</span> <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
	<span class="token keyword">SET</span> <span class="token variable">@old_pro_num_sum</span> <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
	<span class="token keyword">SET</span> <span class="token variable">@old_pro_num_avg</span> <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
	<span class="token keyword">SET</span> <span class="token variable">@old_pro_count</span> <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
	<span class="token comment"># &#x67E5;&#x8BE2;&#x51FA;&#x4E4B;&#x524D;&#x7684;&#x4FE1;&#x606F;&#x7136;&#x540E;&#x8BB0;&#x5F55;&#x5230;&#x4E0D;&#x540C;&#x7684;&#x53D8;&#x91CF;&#x4E2D;</span>
	<span class="token keyword">SELECT</span>
		IFNULL<span class="token punctuation">(</span>pro_price_sum<span class="token punctuation">,</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span>IFNULL<span class="token punctuation">(</span>pro_price_avg<span class="token punctuation">,</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
		IFNULL<span class="token punctuation">(</span>pro_num_sum<span class="token punctuation">,</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span>IFNULL<span class="token punctuation">(</span>pro_num_avg<span class="token punctuation">,</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
		IFNULL<span class="token punctuation">(</span>pro_count<span class="token punctuation">,</span><span class="token number">0</span><span class="token punctuation">)</span>
	<span class="token keyword">FROM</span>
		purchase_mv
	<span class="token keyword">WHERE</span>
		supply_name <span class="token operator">=</span> NEW<span class="token punctuation">.</span>supply_name
	<span class="token keyword">INTO</span>
		<span class="token variable">@old_pro_price_sum</span><span class="token punctuation">,</span><span class="token variable">@old_pro_price_avg</span><span class="token punctuation">,</span><span class="token variable">@old_pro_num_sum</span><span class="token punctuation">,</span><span class="token variable">@old_pro_num_avg</span><span class="token punctuation">,</span><span class="token variable">@old_pro_count</span><span class="token punctuation">;</span>
	<span class="token comment"># &#x7136;&#x540E;&#x518D;&#x53BB;&#x8BA1;&#x7B97;&#x66F4;&#x65B0;&#x64CD;&#x4F5C;&#x4E4B;&#x540E;&#x7684;&#x5185;&#x5BB9;</span>
	<span class="token keyword">SET</span> <span class="token variable">@new_pro_count</span> <span class="token operator">=</span> <span class="token variable">@old_pro_count</span> <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">;</span>
	<span class="token keyword">SET</span> <span class="token variable">@new_pro_price_sum</span> <span class="token operator">=</span> <span class="token variable">@old_pro_price_sum</span> <span class="token operator">+</span> NEW<span class="token punctuation">.</span>pro_price<span class="token punctuation">;</span>
	<span class="token keyword">SET</span> <span class="token variable">@new_pro_price_avg</span> <span class="token operator">=</span> <span class="token variable">@new_pro_price_sum</span> <span class="token operator">/</span> <span class="token variable">@new_pro_count</span><span class="token punctuation">;</span>

	<span class="token keyword">SET</span> <span class="token variable">@new_pro_num_sum</span> <span class="token operator">=</span> <span class="token variable">@old_pro_num_sum</span> <span class="token operator">+</span> NEW<span class="token punctuation">.</span>pro_num<span class="token punctuation">;</span>
	<span class="token keyword">SET</span> <span class="token variable">@new_pro_num_avg</span> <span class="token operator">=</span> <span class="token variable">@new_pro_num_sum</span> <span class="token operator">/</span> <span class="token variable">@new_pro_count</span><span class="token punctuation">;</span>

	<span class="token keyword">REPLACE</span> <span class="token keyword">INTO</span>
		purchase_mv
	<span class="token keyword">VALUES</span><span class="token punctuation">(</span>
		NEW<span class="token punctuation">.</span>supply_name<span class="token punctuation">,</span> <span class="token variable">@new_pro_count</span><span class="token punctuation">,</span>
		<span class="token variable">@new_pro_price_sum</span><span class="token punctuation">,</span> IFNULL<span class="token punctuation">(</span><span class="token variable">@new_pro_price_avg</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
		<span class="token variable">@new_pro_num_sum</span><span class="token punctuation">,</span> IFNULL<span class="token punctuation">(</span><span class="token variable">@new_pro_num_avg</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span>
	<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">END</span><span class="token punctuation">;</span>
$$
<span class="token keyword">DELIMITER</span> <span class="token punctuation">;</span>

<span class="token operator">=</span> &#x8868;&#x53EF;&#x80FD;&#x4F1A;&#x6539;&#x53D8;
<span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> purchase_mv<span class="token punctuation">(</span>
	supply_name <span class="token keyword">VARCHAR</span><span class="token punctuation">(</span><span class="token number">60</span><span class="token punctuation">)</span>  <span class="token operator">NOT</span> <span class="token boolean">NULL</span> <span class="token punctuation">,</span>
	pro_count <span class="token keyword">INT</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
	pro_price_sum <span class="token keyword">INT</span>  <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
	pro_price_avg <span class="token keyword">FLOAT</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
	pro_num_sum <span class="token keyword">INT</span>  <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
	pro_num_avg <span class="token keyword">FLOAT</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
  <span class="token keyword">UNIQUE</span> <span class="token keyword">INDEX</span> supply_name <span class="token punctuation">(</span>supply_name<span class="token punctuation">)</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span>

&#x7269;&#x5316;&#x89C6;&#x56FE; <span class="token operator">-</span><span class="token operator">&gt;</span> &#x5B58;&#x50A8;&#x8FC7;&#x7A0B; &#x548C; &#x89E6;&#x53D1;&#x5668;&#x7684; &#x7EFC;&#x5408;&#x5E94;&#x7528;
&#x8868;&#x7684;&#x6570;&#x636E;&#x5927; : &#x6709;&#x4E9B;&#x5185;&#x5BB9;&#x5F88;&#x9891;&#x7E41;&#x67E5;&#x8BE2;
</pre><h4 class="mume-header" id="12-%E5%AD%98%E5%82%A8%E8%BF%87%E7%A8%8B%E4%B8%8E%E8%A7%A6%E5%8F%91%E5%99%A8%E5%8C%BA%E5%88%AB%E6%98%AF">1.2 &#x5B58;&#x50A8;&#x8FC7;&#x7A0B;&#x4E0E;&#x89E6;&#x53D1;&#x5668;&#x533A;&#x522B;&#x662F;&#xFF1F;</h4>

<p>&#x5B58;&#x50A8;&#x8FC7;&#x7A0B; =&gt; &#x4E3B;&#x52A8; &#x6280;&#x80FD; ( &#x51FD;&#x6570; )<br>
&#x89E6;&#x53D1;&#x5668;   =&gt; &#x88AB;&#x52A8; &#x6280;&#x80FD; ( &#x51FD;&#x6570; )</p>
<h2 class="mume-header" id="2-%E4%BA%8B%E5%8A%A1">2. &#x4E8B;&#x52A1;:</h2>

<h5 class="mume-header" id="10-myisam%E5%AE%9E%E7%8E%B0%E4%BA%8B%E5%8A%A1">1.0 MyISAM&#x5B9E;&#x73B0;&#x4E8B;&#x52A1;</h5>

<p>&#x901A;&#x8FC7;&#x8868;&#x9501;&#x5B9E;&#x73B0;&#x4F2A;&#x4E8B;&#x52A1;</p>
<h5 class="mume-header" id="11-%E4%BA%8B%E5%8A%A1%E7%9A%84%E6%A6%82%E5%BF%B5">1.1 &#x4E8B;&#x52A1;&#x7684;&#x6982;&#x5FF5;</h5>

<p>&#x4E8B;&#x52A1;&#x5904;&#x7406;&#x53EF;&#x4EE5;&#x786E;&#x4FDD;&#x9664;&#x975E;&#x4E8B;&#x52A1;&#x6027;&#x5355;&#x5143;&#x5185;&#x7684;&#x6240;&#x6709;&#x64CD;&#x4F5C;&#x90FD;&#x6210;&#x529F;&#x5B8C;&#x6210;&#xFF0C;&#x5426;&#x5219;&#x4E0D;&#x4F1A;&#x6C38;&#x8FDC;&#x66F4;&#x65B0;&#x9762;&#x5411;&#x6570;&#x636E;&#x7684;&#x8D44;&#x6E90;&#x3002;&#x901A;&#x8FC7;&#x5C06;&#x4E00;&#x7EC4;&#x76F8;&#x5173;&#x64CD;&#x4F5C;&#x7EC4;&#x5408;&#x4E3A;&#x4E00;&#x4E2A;&#x8981;&#x4E48;&#x5168;&#x90E8;&#x6210;&#x529F;&#x8981;&#x4E48;&#x5168;&#x90E8;&#x5931;&#x8D25;&#x7684;&#x5355;&#x5143;&#xFF0C;&#x53EF;&#x4EE5;&#x7B80;&#x5316;&#x9519;&#x8BEF;&#x6062;&#x590D;&#x75C5;&#x53F2;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x66F4;&#x52A0;&#x53EF;&#x9760;&#x3002;&#x4E00;&#x4E2A;&#x903B;&#x8F91;&#x5171;&#x594F;&#x5355;&#x5143;&#x8981;&#x6210;&#x4E3A;&#x4E8B;&#x52A1;&#xFF0C;&#x5FC5;&#x987B;&#x6EE1;&#x8DB3;&#x6240;&#x8C13;&#x7684;ACID&#xFF08;&#x539F;&#x5B50;&#x6027;&#x3001;&#x4E00;&#x81F4;&#x6027;&#x3001;&#x9694;&#x79BB;&#x6027;&#x548C;&#x6301;&#x4E45;&#x6027;&#xFF09;&#x5C5E;&#x6027;&#xFF1A;</p>
<ol>
<li>&#x539F;&#x5B50;&#x6027;&#xFF08;A&#xFF09;
<ul>
<li>&#x5BF9;&#x4E8E;&#x6570;&#x636E;&#x4FEE;&#x6539;&#xFF0C;&#x8981;&#x4E48;&#x5168;&#x90E8;&#x90FD;&#x6267;&#x884C;&#xFF0C;&#x8981;&#x4E48;&#x5168;&#x90FD;&#x4E0D;&#x6267;&#x884C;&#x3002;</li>
</ul>
</li>
<li>&#x9694;&#x79BB;&#x6027;&#xFF08;C&#xFF09;
<ul>
<li>&#x5728;&#x6240;&#x6709;&#x7684;&#x64CD;&#x4F5C;&#x6CA1;&#x6709;&#x6267;&#x884C;&#x5B8C;&#x6BD5;&#x4E4B;&#x524D;&#xFF0C;&#x5176;&#x4ED6;&#x4F1A;&#x8BDD;&#x4E0D;&#x80FD;&#x591F;&#x770B;&#x5230;&#x4E2D;&#x95F4;&#x6539;&#x53D8;&#x7684;&#x8FC7;&#x7A0B;&#x3002;</li>
</ul>
</li>
<li>&#x4E00;&#x81F4;&#x6027;&#xFF08;I&#xFF09;
<ul>
<li>&#x4E8B;&#x52A1;&#x53D1;&#x751F;&#x524D;&#x548C;&#x53D1;&#x751F;&#x540E;&#xFF0C;&#x6839;&#x636E;&#x6570;&#x636E;&#x7684;&#x89C4;&#x5219;&#xFF0C;&#x603B;&#x989D;&#x5E94;&#x8BE5;&#x5339;&#x914D;&#x3002;</li>
</ul>
</li>
<li>&#x6301;&#x4E45;&#x6027;&#xFF08;D&#xFF09;
<ul>
<li>&#x4E8B;&#x52A1;&#x4E00;&#x65E6;&#x88AB;&#x63D0;&#x4EA4;&#xFF0C;&#x5176;&#x7ED3;&#x679C;&#x5C31;&#x662F;&#x6C38;&#x4E45;&#x6027;&#x7684;&#xFF0C;&#x7CFB;&#x7EDF;&#x5D29;&#x6E83;&#x4E5F;&#x4E0D;&#x4F1A;&#x5F71;&#x54CD;</li>
</ul>
</li>
</ol>
<p>&#x5E94;&#x7528;&#x573A;&#x666F;:&#x4F7F;&#x7528;&#x573A;&#x666F;&#x4E00;&#x822C;&#x6D89;&#x53CA;&#x5230;&#x4E2A;&#x4EBA;&#x8D22;&#x52A1;&#x4FE1;&#x606F;&#x7684;&#x65F6;&#x5019;&#x90FD;&#x4F1A;&#x4F7F;&#x7528;&#x5230;&#xFF0C;&#x6BD4;&#x5982;&#x4E0A;&#x56FE;&#x7684;&#x79EF;&#x5206;&#x8BA1;&#x7B97;,&#x8FD8;&#x6709;&#x8BA2;&#x5355;&#x8D2D;&#x7269;&#x8F66;&#x7B49;</p>
<pre data-role="codeBlock" data-info="sql" class="language-sql"><span class="token keyword">start</span> <span class="token keyword">transaction</span><span class="token punctuation">;</span> &#x5F00;&#x542F;&#x4E8B;&#x52A1;
<span class="token keyword">insert</span> <span class="token keyword">into</span> <span class="token function">count</span> <span class="token punctuation">(</span>prefix<span class="token punctuation">,</span>count<span class="token punctuation">,</span>historyCount<span class="token punctuation">)</span><span class="token keyword">values</span><span class="token punctuation">(</span><span class="token string">&apos;dyi&apos;</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">select</span> <span class="token operator">*</span> <span class="token keyword">from</span> count
<span class="token keyword">commit</span><span class="token punctuation">;</span>
</pre><p><img src="assets/markdown-img-paste-20190327223126157.png" alt></p>
<h5 class="mume-header" id="14-%E4%BA%8B%E5%8A%A1%E7%9A%84%E5%AE%9E%E7%8E%B0-%E7%B1%BB%E4%BC%BC%E7%94%B5%E5%BD%B1%E9%A2%84%E7%9F%A5%E6%9C%AA%E6%9D%A5">1.4 &#x4E8B;&#x52A1;&#x7684;&#x5B9E;&#x73B0; -- &#xFF08;&#x7C7B;&#x4F3C;&#x7535;&#x5F71;&#x300A;&#x9884;&#x77E5;&#x672A;&#x6765;&#x300B;&#xFF09;</h5>

<p>&#x5B58;&#x50A8;&#x5F15;&#x64CE;&#x7B80;&#x5355;&#x77A7;&#x77A7;&#x540E;&#x9762;&#x7EC6;&#x8BB2;</p>
<p><img src="assets/markdown-img-paste-20190327220036136.png" alt></p>
<p>&#x56E0;&#x4E3A;MySQL5&#x4E4B;&#x540E;&#x901A;&#x5E38;&#x7684;&#x9ED8;&#x8BA4;&#x5B58;&#x50A8;&#x5F15;&#x64CE;&#x662F;InnoDB&#x6240;&#x4EE5;&#xFF0C;&#x4EE5;InnoDB&#x4E3A;&#x4F8B;&#x8BB2;&#x89E3;&#x5B9E;&#x73B0;&#x8FC7;&#x7A0B;</p>
<p>MySQL&#x5728;&#x8FDB;&#x884C;&#x4E8B;&#x52A1;&#x5904;&#x7406;&#x7684;&#x65F6;&#x5019;&#x4F7F;&#x7528;&#x7684;&#x662F;&#x65E5;&#x5FD7;&#x73B0;&#x884C;&#x7684;&#x65B9;&#x5F0F;&#x6765;&#x4FDD;&#x8BC1;&#x4E8B;&#x52A1;&#x53EF;&#x5FEB;&#x901F;&#x548C;&#x6301;&#x4E45;&#x8FD0;&#x884C;&#x7684;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x5728;&#x5199;&#x6570;&#x636E;&#x5E93;&#x524D;&#xFF0C;&#x9700;&#x8981;&#x5148;&#x5199;&#x65E5;&#x5FD7;&#x3002;&#x5F53;&#x5F00;&#x59CB;&#x4E00;&#x4E2A;&#x4E8B;&#x52A1;&#x65F6;&#xFF0C;&#x4F1A;&#x8BB0;&#x5F55;&#x8BE5;&#x4E8B;&#x7269;&#x7684;&#x4E00;&#x4E2A;LSN&#x65E5;&#x5FD7;&#x5E8F;&#x5217;&#x53F7;&#xFF1B;&#x5F53;&#x6267;&#x884C;&#x4E8B;&#x52A1;&#x65F6;&#xFF0C;&#x4F1A;&#x5F80;InnoDB_Log_Buffer &#x65E5;&#x5FD7;&#x7F13;&#x51B2;&#x533A;&#x91CC;&#x63D2;&#x5165;&#x4E8B;&#x52A1;&#x65E5;&#x5FD7;&#xFF08;redo log&#xFF09;;&#x5F53;&#x4E8B;&#x52A1;&#x63D0;&#x4EA4;&#x65F6;&#xFF0C;&#x4F1A;&#x5C06;&#x65E5;&#x5FD7;&#x7F13;&#x5B58;&#x533A;&#x91CC;&#x7684;&#x4E8B;&#x52A1;&#x65E5;&#x5FD7;&#x5237;&#x5165;&#x78C1;&#x76D8;&#x3002;&#x8FD9;&#x4E2A;&#x52A8;&#x4F5C;&#x4E3B;&#x8981;&#x662F;&#x7531;innodb_flush_log_at_trx_commit&#x8FD9;&#x4E2A;&#x53C2;&#x6570;&#x63A7;&#x5236;&#x7684;&#x3002;</p>
<ol>
<li>&#x53D1;&#x51FA;commit&#x52A8;&#x4F5C;&#x65F6;&#x3002;&#x5DF2;&#x7ECF;&#x8BF4;&#x660E;&#x8FC7;&#xFF0C;commit&#x53D1;&#x51FA;&#x540E;&#x662F;&#x5426;&#x5237;&#x65E5;&#x5FD7;&#x7531;&#x53D8;&#x91CF; innodb_flush_log_at_trx_commit &#x63A7;&#x5236;&#x3002;</li>
<li>&#x6BCF;&#x79D2;&#x5237;&#x4E00;&#x6B21;&#x3002;&#x8FD9;&#x4E2A;&#x5237;&#x65E5;&#x5FD7;&#x7684;&#x9891;&#x7387;&#x7531;&#x53D8;&#x91CF; innodb_flush_log_at_timeout &#x503C;&#x51B3;&#x5B9A;&#xFF0C;&#x9ED8;&#x8BA4;&#x662F;1&#x79D2;&#x3002;&#x8981;&#x6CE8;&#x610F;&#xFF0C;&#x8FD9;&#x4E2A;&#x5237;&#x65E5;&#x5FD7;&#x9891;&#x7387;&#x548C;commit&#x52A8;&#x4F5C;&#x65E0;&#x5173;&#x3002;</li>
<li>&#x5F53;log buffer&#x4E2D;&#x5DF2;&#x7ECF;&#x4F7F;&#x7528;&#x7684;&#x5185;&#x5B58;&#x8D85;&#x8FC7;&#x4E00;&#x534A;&#x65F6;&#x3002;</li>
<li>&#x5F53;&#x6709;checkpoint&#x65F6;&#xFF0C;checkpoint&#x5728;&#x4E00;&#x5B9A;&#x7A0B;&#x5EA6;&#x4E0A;&#x4EE3;&#x8868;&#x4E86;&#x5237;&#x5230;&#x78C1;&#x76D8;&#x65F6;&#x65E5;&#x5FD7;&#x6240;&#x5904;&#x7684;LSN&#x4F4D;&#x7F6E;&#x3002;</li>
</ol>
<p>&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x547D;&#x4EE4;</p>
<pre data-role="codeBlock" data-info="sql" class="language-sql"><span class="token keyword">show</span> <span class="token keyword">engine</span> <span class="token keyword">innodb</span> <span class="token keyword">status</span>\G<span class="token punctuation">;</span>
</pre><blockquote>
<p>Log sequence number 8619676075 (&#x8868;&#x793A;&#x5F53;&#x524D;&#x7684;LSN&#x65E5;&#x5FD7;&#x5E8F;&#x5217;&#x53F7;)<br><br>
Log flushed up to   8619676075 (&#x8868;&#x793A;&#x5237;&#x65B0;&#x5230;&#x4E8B;&#x7269;&#x65E5;&#x5FD7;&#x7684;LSN&#x65E5;&#x5FD7;&#x5E8F;&#x5217;&#x53F7;)<br><br>
Last checkpoint at  8619676075 (&#x8868;&#x793A;&#x5237;&#x65B0;&#x5230;&#x78C1;&#x76D8;&#x7684;LSN&#x65E5;&#x5FD7;&#x5E8F;&#x5217;&#x53F7;)</p>
</blockquote>
<p>&#x9664;&#x4E86;&#x8BB0;&#x5F55;&#x4E8B;&#x52A1;&#x65E5;&#x5FD7;&#x610F;&#x5916;&#xFF0C;&#x6570;&#x636E;&#x5E93;&#x8FD8;&#x4F1A;&#x8BB0;&#x5F55;&#x4E00;&#x5B9A;&#x91CF;&#x7684;&#x64A4;&#x9500;&#x65E5;&#x5FD7;(undo log)&#xFF0C; undo&#x4E0E;redo&#x6B63;&#x597D;&#x76F8;&#x53CD;&#xFF0C;&#x5728;&#x5BF9;&#x6570;&#x636E;&#x8FDB;&#x884C;&#x4FEE;&#x6539;&#x65F6;&#xFF0C;&#x7531;&#x4E8E;&#x67D0;&#x79CD;&#x539F;&#x56E0;&#x5931;&#x8D25;&#x4E86;&#xFF0C;&#x6216;&#x8005;&#x4EBA;&#x4E3A;&#x6267;&#x884C;&#x4E86;rollback&#x56DE;&#x6EDA;&#x8BED;&#x53E5;&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x5229;&#x7528;&#x8FD9;&#x4E9B;&#x64A4;&#x9500;&#x65E5;&#x5FD7;&#x5C06;&#x6570;&#x636E;&#x56DE;&#x6EDA;&#x5230;&#x4FEE;&#x6539;&#x4E4B;&#x524D;&#x7684;&#x6837;&#x5B50;&#x3002;redo&#x65E5;&#x5FD7;&#x4FDD;&#x5B58;&#x5728;ib_logfile0/1/2&#x91CC;&#xFF0C;&#x800C;undo&#x65E5;&#x5FD7;&#x4FDD;&#x5B58;&#x5728;ibdata1&#x91CC;&#xFF0C;&#x5728;MySQL5.6&#x91CC;&#x8FD8;&#x53EF;&#x4EE5;&#x628A;undo&#x65E5;&#x5FD7;&#x5355;&#x62C6;&#x5206;&#x51FA;&#x53BB;&#x3002;</p>
<h5 class="mume-header" id="15-%E5%88%86%E5%B8%83%E5%BC%8F%E4%BA%8B%E5%8A%A1%E4%BA%86%E8%A7%A3">1.5 &#x5206;&#x5E03;&#x5F0F;&#x4E8B;&#x52A1;&#xFF08;&#x4E86;&#x89E3;&#xFF09;</h5>

<p>&#x8D44;&#x6E90;&#x7BA1;&#x7406;&#x5668;&#xFF1A;&#x7BA1;&#x7406;&#x4E8B;&#x52A1;&#x7684;&#x63D0;&#x4EA4;&#x548C;&#x56DE;&#x6EDA;&#xFF0C;&#x5411;&#x4E8B;&#x52A1;&#x63D0;&#x4F9B;&#x8D44;&#x6E90;&#x3002;<br>
&#x4E8B;&#x52A1;&#x7BA1;&#x7406;&#x5668;&#xFF1A;&#x548C;&#x8D44;&#x6E90;&#x7BA1;&#x7406;&#x5668;&#x901A;&#x4FE1;&#xFF0C;&#x534F;&#x8C03;&#x5B8C;&#x6210;&#x4E8B;&#x52A1;&#x7684;&#x5904;&#x7406;&#x3002;</p>
<p>&#x7528;&#x4E8E;&#x6267;&#x884C;&#x5206;&#x5E03;&#x5F0F;&#x4E8B;&#x52A1;&#x7684;&#x8FC7;&#x7A0B;&#x4F7F;&#x7528;&#x4E24;&#x4E2A;&#x9636;&#x6BB5;&#xFF1B;<br>
&#xFF08;1&#xFF09;&#x7B2C;&#x4E00;&#x9636;&#x6BB5;&#xFF1A;&#x6240;&#x6709;&#x7684;&#x5206;&#x652F;&#x88AB;&#x9884;&#x5907;&#x3002;&#x4ED6;&#x4EEC;&#x88AB;&#x4E8B;&#x52A1;&#x7BA1;&#x7406;&#x5668;&#x544A;&#x77E5;&#x8981;&#x51C6;&#x5907;&#x63D0;&#x4EA4;&#xFF0C;&#x6BCF;&#x4E2A;&#x5206;&#x652F;&#x8D44;&#x6E90;&#x7BA1;&#x7406;&#x5668;&#x8BB0;&#x5F55;&#x5206;&#x652F;&#x7684;&#x884C;&#x52A8;&#x5E76;&#x6307;&#x793A;&#x8BA4;&#x4E3A;&#x7684;&#x53EF;&#x884C;&#x6027;&#x3002;<br>
&#xFF08;2&#xFF09;&#x7B2C;&#x4E8C;&#x9636;&#x6BB5;&#xFF1A;&#x4E8B;&#x52A1;&#x7BA1;&#x7406;&#x5668;&#x544A;&#x77E5;&#x8D44;&#x6E90;&#x7BA1;&#x7406;&#x5668;&#x662F;&#x5426;&#x8981;&#x63D0;&#x4EA4;&#x6216;&#x8005;&#x56DE;&#x6EDA;&#x3002;&#x5982;&#x679C;&#x9884;&#x5907;&#x5206;&#x5B50;&#x65F6;&#xFF0C;&#x6240;&#x6709;&#x7684;&#x5206;&#x652F;&#x6307;&#x793A;&#x4ED6;&#x4EEC;&#x5C06;&#x80FD;&#x591F;&#x63D0;&#x4EA4;&#xFF0C;&#x90A3;&#x4E48;&#x6240;&#x6709;&#x7684;&#x5206;&#x652F;&#x88AB;&#x544A;&#x77E5;&#x63D0;&#x4EA4;&#x3002;&#x5982;&#x679C;&#x6709;&#x4E00;&#x4E2A;&#x5206;&#x652F;&#x51FA;&#x9519;&#xFF0C;&#x90A3;&#x4E48;&#x5C31;&#x5168;&#x90E8;&#x90FD;&#x8981;&#x56DE;&#x6EDA;&#x3002;&#x7279;&#x6B8A;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x53EA;&#x6709;&#x4E00;&#x4E2A;&#x5206;&#x652F;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x7B2C;&#x4E8C;&#x9636;&#x6BB5;&#x5219;&#x88AB;&#x7701;&#x7565;&#x3002;</p>
<p>&#x5206;&#x5E03;&#x5F0F;&#x4E8B;&#x52A1;&#x4E3B;&#x8981;&#x4F5C;&#x7528;&#x5728;&#x4E8E;&#x786E;&#x4FDD;&#x4E8B;&#x52A1;&#x7684;&#x4E00;&#x81F4;&#x6027;&#x548C;&#x5B8C;&#x6574;&#x6027;&#x3002;&#x4ED6;&#x5229;&#x7528;&#x5206;&#x5E03;&#x5F0F;&#x7684;&#x8BA1;&#x7B97;&#x73AF;&#x5883;&#xFF0C;&#x5C06;&#x591A;&#x4E2A;&#x4E8B;&#x52A1;&#x6027;&#x7684;&#x6D3B;&#x52A8;&#x5408;&#x5E76;&#x6210;&#x4E00;&#x4E2A;&#x4E8B;&#x52A1;&#x5355;&#x5143;&#xFF0C;&#x8FD9;&#x4E9B;&#x4E8B;&#x52A1;&#x7EC4;&#x5408;&#x5728;&#x4E00;&#x8D77;&#x6784;&#x6210;&#x539F;&#x5B50;&#x64CD;&#x4F5C;&#xFF0C;&#x8FD9;&#x4E9B;&#x4E8B;&#x52A1;&#x7684;&#x6D3B;&#x52A8;&#x8981;&#x4E48;&#x4E00;&#x8D77;&#x6267;&#x884C;&#x5E76;&#x63D0;&#x4EA4;&#x4E8B;&#x52A1;&#xFF0C;&#x8981;&#x4E48;&#x56DE;&#x6EDA;&#x6240;&#x6709;&#x7684;&#x64CD;&#x4F5C;&#xFF0C;&#x4ECE;&#x800C;&#x4FDD;&#x8BC1;&#x4E86;&#x591A;&#x4E2A;&#x6D3B;&#x52A8;&#x4E4B;&#x95F4;&#x7684;&#x4E00;&#x81F4;&#x6027;&#x548C;&#x5B8C;&#x6574;&#x6027;&#x3002;</p>

      </div>
      
      
    
    
    
    
    
    
    
    
  
    </body></html>